package com.yichen.music;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.music.Utils.AllCateUtil;
import com.yichen.util.Home_List_Adapter;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.AvoidXfermode;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;

/**
 * 主页
 * 
 * @author yangyong
 * 
 */

public class MusicMusicActivity extends Activity implements OnItemClickListener {

	private static String[] data = new String[] { "榜单", "歌手", "专辑", "分类", "其他" };
	private static int[] imgdata = new int[] { R.drawable.bangdan,
			R.drawable.actor, R.drawable.zhuanji, R.drawable.cate,
			R.drawable.other };

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		init();

	}

	private void init() {
		// TODO Auto-generated method stub
		setContentView(R.layout.public_list_layout);
		ListView cate_list = (ListView) findViewById(R.id.cate_list);

		// ArrayAdapter<String> cate_adapter = new ArrayAdapter<String>(this,
		// R.layout.list_item_home, data);
		// ArrayAdapter<String> cate_adapter = new ArrayAdapter<String>(this,
		// R.layout.list_item_home, R.id.name_text, data);

		List<HashMap<String, Object>> adapter_data = new ArrayList<HashMap<String, Object>>();

		for (int i = 0; i < data.length; i++) {
			Map<String, Object> item_map = new HashMap<String, Object>();
			item_map.put("img", imgdata[i]);
			item_map.put("name", data[i]);
			adapter_data.add((HashMap<String, Object>) item_map);

		}

		Home_List_Adapter home_adapter = new Home_List_Adapter(adapter_data,
				this);
		cate_list.setOnItemClickListener(this);
		// cate_list.setSelector(R.drawable.blue_yellow_press);
		cate_list.setAdapter(home_adapter);
	}

	private void jump(Class<Activity> ad) {
		// TODO Auto-generated method stub
		Intent intent = new Intent();
		intent.setClass(this, ad);
		startActivity(intent);

	}

	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		// TODO Auto-generated method stub
		Intent intent = new Intent();
		switch (arg2) {
		case 0:// 榜单
			intent.setClass(this, BillboardList.class);

			break;
		case 1:// 歌手
			intent.setClass(this, ActorsCateList.class);
			break;
		case 2:// 专辑
			intent.setClass(this, LbumCateList.class);
			break;
		case 3:// 分类
			intent.setClass(this, MusicCateList.class);
			break;
		case 4:// 其他
				// intent.setClass(this, CateList.class);

			new AllCateUtil().getbigCate();

			break;

		default:
			break;
		}
		startActivity(intent);
	}
}